package com.xtaller.easy.admin.mapper;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.xtaller.easy.admin.model.SysRole;

import com.xtaller.easy.admin.model.SysRoleModule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* Created by Taller on 2018/04/13
*/
@Mapper 
public interface SysRoleMapper extends BaseMapper<SysRole> {
    @Select("select * from base_user_role where isDel=0 and roleId=#{roleId}")
    List<JSONObject> getByRole(@Param("roleId") String roleId);
    @Select("select * from v_role_module")
    List<JSONObject> getRoleModule();
    @Update("update sys_role_module set isDel=1,reviser=#{w.reviser}," +
            "reviseTime=#{w.reviseTime} where roleId=#{w.roleId} and isDel=0")
    Boolean initRoleModule(@Param("w") SysRoleModule model);

    // 初始化权限信息
    @Update("delete from sys_role_auth where roleId=#{roleId}")
    Boolean initAuth(@Param("roleId") String roleId);
}